# https://www.bilibili.com/video/BV1W7411G7wP?p=16&spm_id_from=pageDriver&vd_source=8bd7b24b38e3e12c558d839b352b32f4
# =IFNA(VLOOKUP(A2,Scores!A2:B21,2,FALSE),0)
#
import pandas as pd
import matplotlib.pyplot as plt

# 使用pandas没有指定ID的情况下
students = pd.read_excel('../resources/input_py_tools/016/Student_Score.xlsx', sheet_name='Students')
scores = pd.read_excel('../resources/input_py_tools/016/Student_Score.xlsx', sheet_name='Scores')
print(students)
print(scores)

# 示例1 "内连接" how='inner' 默认
table_inner = students.merge(scores, on='ID')
print(table_inner)

# 示例2 "左外连接"
table_left = students.merge(scores, on='ID', how='left').fillna(0)
table_left.Score = table_left.Score.astype(int) # 把Score那一列格式设置为int
print(table_left)

